import Vue from 'vue'
import Vonic from 'vonic/src/index.js'
import axios from 'axios'
import './jquery.lazyload.js'
Vue.prototype.axios=axios


// Page Components
import TabBar from './pages/tabbar.vue'
import Home from './pages/tabbar/home.vue'
// Routes
const routes = [
    {
        path: '/',
        component: TabBar,
        redirect:'/home',
        children: [
            { path: 'home', component: Home },
            { path: 'destination', component: resolve=>{require(['./pages/tabbar/destination.vue'],resolve)} },
            { path: 'mytrip', component: resolve=>{require(['./pages/tabbar/mytrip.vue'],resolve)} },
            { path: 'mynews', component: resolve=>{require(['./pages/tabbar/mynews.vue'],resolve)} },
            { path: 'mine', component: resolve=>{require(['./pages/tabbar/mine.vue'],resolve)} }
        ]
    },
    {
        path:'/imagelist/:id',
        component: resolve=>{require(['./pages/imagelist'],resolve)}
    },
    {
        path:'/sixlist/:name',
        component: resolve=>{require(['./pages/sixlist'],resolve)}
    },
    {
        path:'/detaillist/:id',
        component: resolve=>{require(['./pages/detaillist'],resolve)}
    },
    ,
    {
        path:'/searchcity/:cityId',
        component: resolve=>{require(['./pages/searchcity'],resolve)}
    },
    {
        path:'/searchword/:word',
        component: resolve=>{require(['./pages/searchword'],resolve)}
    },
    {
        path:'/login',
        component: resolve=>{require(['./pages/login'],resolve)}
    },
    {
        path:'/register',
        component: resolve=>{require(['./pages/register'],resolve)}
    },
    {
        path:'/feedback',
        component: resolve=>{require(['./pages/feedback'],resolve)}
    },
    {
        path:'/visa',
        component: resolve=>{require(['./pages/visa'],resolve)}
    },
    {
        path:'/visadetail/:city',
        component: resolve=>{require(['./pages/visadetail'],resolve)}
    },
    {
        path:'/custompackage',
        component: resolve=>{require(['./pages/custompackage'],resolve)}
    },
    {
        path:'/customPackageSubmit',
        component: resolve=>{require(['./pages/customPackageSubmit'],resolve)}
    }
]

Vue.filter('imageFilter',value=>{
    if(value.substr(0,1)=='h'){
        return value+'?imageView2/1/w/420/h/243/q/75/format/jpg'
    }else{
        return 'http://dn-toursforfun.qbox.me/images/'+ value + '?imageView2/1/w/720/h/404/q/90/format/jpg'
    }
})
Vue.filter('persent',value=>{
    return parseFloat( value).toFixed(1)+'%'
})
Vue.filter('time',value=>{
    return value.substr(0,10)
})
Vue.use(Vonic.app, {
  routes: routes
})
